package main

import (
	"encoding/json"
	"fmt"
)

// 规格值
type SpecValue struct {
	SpecValueId int     `json:"specValueId"`
	SpecValue   string  `json:"specValue"`
	Image       *string `json:"image"`
	CheckState  int     `json:"checkState"`
}

// 规格
type Spec struct {
	SpecId        int         `json:"specId"`
	SpecName      string      `json:"specName"`
	SpecValueList []SpecValue `json:"specValueList"`
}

// 默认产品信息
type DefaultProduct struct {
	ProductId       int      `json:"productId"`
	GoodsName       string   `json:"goodsName"`
	GetSpecValueIds string   `json:"getSpecValueIds"`
	GetSpecValues   string   `json:"getSpecValues"`
	ProductPrice    float64  `json:"productPrice"`
	MarketPrice     float64  `json:"marketPrice"`
	SuperPrice      *float64 `json:"superPrice"`
	SaveAmount      *float64 `json:"saveAmount"`
	ProductStock    int      `json:"productStock"`
	ActualSales     int      `json:"actualSales"`
	GoodsPics       []string `json:"goodsPics"`
	PromotionType   *string  `json:"promotionType"`
	PromotionId     *string  `json:"promotionId"`
}

// 数据部分
type Data struct {
	ShareImage     string         `json:"shareImage"`
	ShareLink      string         `json:"shareLink"`
	Specs          []Spec         `json:"specs"`
	DefaultProduct DefaultProduct `json:"defaultProduct"`
}

// 最外层 JSON 结构
type Response struct {
	Data      Data    `json:"data"`
	LogMsg    *string `json:"logMsg"`
	Msg       string  `json:"msg"`
	State     int     `json:"state"`
	Timestamp int64   `json:"timestamp"`
}

func main() {
	// 示例 JSON 数据
	jsonStr := `{
		"data": {
			"shareImage": "https://sg-mall-test.oss-cn-shanghai.aliyuncs.com/b2b2cdevimages/seller/goods/xNdbcrrQwSNKLphjgBn.jpg?bindId=36?x-oss-process=image/resize,w_300,h_300",
			"shareLink": "https://m-test.shengu.shop/standard/product/detail?productId=200001910010",
			"specs": [
				{
					"specId": 7,
					"specName": "尺寸",
					"specValueList": [
						{
							"specValueId": 60,
							"specValue": "9",
							"image": null,
							"checkState": 3
						},
						{
							"specValueId": 95,
							"specValue": "996320",
							"image": null,
							"checkState": 3
						},
						{
							"specValueId": 94,
							"specValue": "998765",
							"image": null,
							"checkState": 3
						},
						{
							"specValueId": 93,
							"specValue": "666777",
							"image": null,
							"checkState": 3
						}
					]
				}
			],
			"defaultProduct": {
				"productId": 200001910010,
				"goodsName": "心理特训第三期",
				"getSpecValueIds": "",
				"getSpecValues": "",
				"productPrice": 0.03,
				"marketPrice": 0,
				"superPrice": null,
				"saveAmount": null,
				"productStock": 99,
				"actualSales": 0,
				"goodsPics": [
					"https://sg-mall-test.oss-cn-shanghai.aliyuncs.com/b2b2cdevimages/seller/goods/xNdbcrrQwSNKLphjgBn.jpg?bindId=36"
				],
				"promotionType": null,
				"promotionId": null
			}
		},
		"logMsg": null,
		"msg": "成功",
		"state": 200,
		"timestamp": 1740641397401
	}`

	// 解析 JSON
	var response Response
	err := json.Unmarshal([]byte(jsonStr), &response)
	if err != nil {
		fmt.Println("解析 JSON 失败:", err)
		return
	}

	// 输出解析后的结构体
	fmt.Printf("%+v\n", response)
}
